import requests


import requests
from django.template.defaultfilters import title

headers = {
    'Accept': 'application/json, text/plain, */*',
    'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
    'Cache-Control': 'no-cache',
    'Connection': 'keep-alive',
    'Content-Type': 'application/json',
    'Origin': 'https://www.dianping.com',
    'Pragma': 'no-cache',
    'Referer': 'https://www.dianping.com/',
    'Sec-Fetch-Dest': 'empty',
    'Sec-Fetch-Mode': 'cors',
    'Sec-Fetch-Site': 'same-site',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36',
    'sec-ch-ua': '"Chromium";v="140", "Not=A?Brand";v="24", "Google Chrome";v="140"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'withCredentials': 'true',
}

json_data = {
    'cityId': 2,
    'pageStart': 1,
    'pageSize': 40,
    'sourceId': 1,
    'lxCuid': '19a3a4b8687c8-0d2f845c074e32-26061951-1fa400-19a3a4b8687c8',
    'awakeAppHandler': 'awakeAppHandler',
    'envParam': {
        'os': 'ios',
        'locCityId': 1,
        'latitude': 0,
        'longitude': 0,
    },
}

response = requests.post('https://mapi.dianping.com/mapi/mgw/growthlistfeeds', headers=headers, json=json_data)

datas = response.json()['result']['feedsRecordDTOS']
# print(datas)
for data in datas:
    title = data['title']
    img_url = data['picKey']
    datil_url = data['schema']
    likeCount = data['likeCount']
    print(title, img_url, datil_url, likeCount)

